package cn.itcast.mq.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SpringDirectListener {
    /**
     * 路由模式的消费者1
     * @param message
     */
    @RabbitListener(bindings = @QueueBinding(

            value = @Queue(name = "sysionDirect.queue1"),
            exchange = @Exchange(name = "sysion.direct",type = ExchangeTypes.DIRECT),
            key = {"greed","blue"}
    ))
    public void listenDirectQueue1(String message){

        System.out.println("消费者接收到direct。queue1的消息：【"+message+"】");
    }

    /**
     * 路由模式的消费者2
     * @param message
     */
    @RabbitListener(bindings = @QueueBinding(

            value = @Queue(name = "sysionDirect.queue2"),
            exchange = @Exchange(name = "sysion.direct2",type = ExchangeTypes.DIRECT),
            key = {"black","blue"}
    ))
    public void listenDirectQueue2(String message){

        System.out.println("消费者接收到direct。queue2的消息：【"+message+"】");
    }

}
